//
//  HYThemePictureView.m
//  _normal
//
//  Created by Ezra on 16/6/7.
//  Copyright © 2016年 Ezra. All rights reserved.
//

#import "HYThemePictureView.h"
#import "HYThemeItem.h"
#import <SDWebImage/UIImageView+WebCache.h>
#import <DALabeledCircularProgressView.h>
#import "HYShowPictureViewController.h"

@interface HYThemePictureView()


@property (weak, nonatomic) IBOutlet UIImageView *pictureView;

//这里去xib的view中该右上角，再连线，他继承自view
@property (weak, nonatomic) IBOutlet DALabeledCircularProgressView *progressView;

@end

@implementation HYThemePictureView

-(void)awakeFromNib
{
    self.progressView.progressLabel.textColor = [UIColor whiteColor];
}

-(void)setItem:(HYThemeItem *)item
{
    [super setItem:item];
    
    self.pictureView.layer.masksToBounds = YES;
    
    self.pictureView.layer.cornerRadius = 20 ;
    
    
    
    NSString * urlStr =  [item.avatar stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    

    
    //下载图片，添加下载视图
    [self.pictureView sd_setImageWithURL:[NSURL URLWithString:urlStr] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
        
        
        
    }];

}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
//    HYShowPictureViewController *showPic = [[HYShowPictureViewController alloc]init];
//    showPic.item = self.item;
//
//    [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:showPic animated:YES completion:nil];
}

@end
